{% extends "master.html" %}
{% block subtitle %} - 修改密码{% endblock %}

{% block extJS %}
<script language="JavaScript" type="text/javascript">
//<![CDATA[
    function toSubmit(){
        var msg = [];
        clearMsg();
        $(".err").removeClass('err');
        
        var oldp = $("#oldpassword");
        if(!oldp.val()){ 
            msg.push('请输入旧的密码！');
            oldp.addClass('err'); 
        }
        
        var newp = $("#newpassword");
        if(!newp.val()){ 
            msg.push('请输入新的密码！');
            newp.addClass('err'); 
        }
        
        var renewp = $("#repassword");
        if(!renewp.val()){ 
            msg.push('请输入确认的密码！'); 
            renewp.addClass('err'); 
        }
        
        if(newp.val() != renewp.val() ){ msg.push('请确保新的密码与确认密码相同！'); }
        if(msg.length > 0){
            alertError(msg);        
            return false;            
        }else{
            //$("form").submit();
        }
            
    }
    
    function toCancel(){
        redirect_alert('{{MSG_LEAVE_WITHOUT_SAVING}}',"{{url_for('bpRoot.view')}}");
    }
//]]>
</script>
{% endblock %}

{% block main %}
<div class="container">
    <div class="row">
        <ol class="breadcrumb">
          <li><a href="#">用户</a></li>
          <li class="active">用户资料</li>
        </ol>
    </div>
    <ul class="nav nav-tabs">
      <li><a href="{{url_for('bpAuth.changePro')}}">用户资料</a></li>
      <li class="active"><a href="#">修改密码</a></li>
      <li><a href="{{url_for('bpAuth.viewLog')}}">日志记录</a></li>
    </ul>
    <div class="row">
        <div class="btn-toolbar pull-right">
            <div class="btn-group"><button class="btn btn-primary" onclick="return toSubmit()">确认</button></div>
            <div class="btn-group"><button class="btn btn-default" onclick="return toCancel()">取消</button></div>
        </div>
    </div>
    <div class="row">
        <div class="col-md-8 col-md-offset-2">
            <form class="form-horizontal" action="{{url_for('bpAuth.changePW')}}" method="post">
                <div class="control-group">
                    <label class="control-label" for="oldpassword">旧密码</label>
                    <div class="controls">
                      <input type="password" id="oldpassword" placeholder="旧密码" name="oldpassword">
                    </div>
                </div>
                
                <div class="control-group">
                    <label class="control-label" for="newpassword">新密码</label>
                    <div class="controls">
                      <input type="password" id="newpassword" placeholder="旧密码" name="newpassword">
                    </div>
                </div>
                
                <div class="control-group">
                    <label class="control-label" for="repassword">确认密码</label>
                    <div class="controls">
                      <input type="password" id="repassword" placeholder="确认密码" name="repassword">
                    </div>
                </div>
          </form>
      </div>
    </div>
</div>
{% endblock %}
